<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Crunchy Frog Editor</title>
<link href="tutor.css" title="Tutor Style" type="text/css" rel="stylesheet" />
<link href="tutor.css" type="text/css" rel="stylesheet" />
<link href="tutor_bw.css" title="Black and white"
type="text/css" rel="stylesheet" />
<link href="tutor_menu.css" title="Tutor Style" type="text/css" rel="stylesheet" />

</head>
<body>
<div id="topbar">
<img alt="" src="absent_minded.gif" class="titleimage"/>
<span class="title">Writing code</span>
</div>
<div id="navbar">
<span class="heading">Crunchy user tutorial</span>
<a href="index.html">Welcome</a>
<a href="interpreter.html">Interpreter</a>
<a href="editor.html">Editor</a>
<a href="doctest.html">DocTest</a>
<a href="canvas.html">Graphics: drawing</a>
<a href="plot.html">Graphics: plotting</a>
<a href="sound.html">Sound</a>
<a href="external.html">External applications</a>
</div>
<div id="main">
<p>Sometimes, you want to write Python code that is <i>*gasp*</i> worth saving.  In this case, rather than using the Python interpreter, you probably resort to your favourite editor which most likely allows you to run your Python code.  Start your favourite editor, and type in (or cut-and-paste) the following example shamelessly lifted from the official Python tutorial.</p>
<pre title="editor size=(8, 80)">
for n in range(2, 10):
    for x in range(2, n):
        if n % x == 0:
            print n, 'equals', x, '*', n/x
            break
    else:
        print n, 'is a prime number'
print a      # will raise an error
</pre>
<p>If you read this page using Crunchy Frog and your favourite browser, you will see that a "text box" with a handy button is located just in between this paragraph and the piece of code above.  So, if you are using Crunchy Frog, you don't need to use an editor to actually try the above <i> long</i> example.</p>
<p>If you do try the example, you will notice that "errors" (output from stderr) are printed in a different colour than "normal" stuff (output from stdout).  And, if you know a bit about Python, you will note that the
familiar traceback messages have been replaced by something less intimidating for beginners.</p>
<p>If you are using Crunchy Frog, you might want to try to type in some code in the other coding area provided just below.  
Why?  Because you can, that's why!</p>
<pre title="editor size=(12, 40)">

</pre>
<p><small>Another link, this time to the <a href="doctest.html">doctest</a>.</small></p>
</div>
</body>
</html>

